var t = require;
var e = module;
var o = exports;
Object.defineProperty(o, "__esModule", { value: !0 });
o.AdTypeEm = o.AdPosEm = void 0;
var a,
    i,
    n = t("AdViewAndroid"),
    r = t("AdViewOppo"),
    s = t("AdViewVivo"),
    c = t("AdViewTT");
(function(t) {
    t[(t.banner = 1)] = "banner";
    t[(t.rewardVideo = 2)] = "rewardVideo";
    t[(t.interstitial = 3)] = "interstitial";
    t[(t.native = 4)] = "native";
    t[(t.custom = 5)] = "custom";
    t[(t.portal = 6)] = "portal";
})((a = o.AdPosEm || (o.AdPosEm = {})));
(function(t) {
    t[(t.upLv = 1)] = "upLv";
    t[(t.foodMax = 2)] = "foodMax";
    t[(t.closeSkill = 3)] = "closeSkill";
    t[(t.equip = 4)] = "equip";
    t[(t.idle = 5)] = "idle";
    t[(t.implant = 6)] = "implant";
    t[(t.box = 7)] = "box";
})((i = o.AdTypeEm || (o.AdTypeEm = {})));
var p = new((function() {
    function t() {
        this.curPlat = "android";
        this.playData = {};
        this.viewAdIndex = 0;
        this.devId = "";
        this.lastCloseTime = 0;
        this.lastClickTime = 0;
        this.isCloseCustomAd = !0;
        this.isCloseInterAd = !0;
    }
    Object.defineProperty(t.prototype, "adData", {
        get: function() {
            return this.playData[this.viewAdIndex];
        },
        enumerable: !1,
        configurable: !0
    });
    t.prototype.setViewIndex = function(t) {
        this.viewAdIndex = t;
    };
    t.prototype.addAdCallBase = function(t) {
        this.playData[this.viewAdIndex] = t;
    };
    t.prototype.getAdBase = function(t) {
        void 0 === t && (t = "android");
        var e = null;
        switch (GameCof.curPlat) {
            case "android":
                e = new n.default();
                break;
            case "oppo":
                e = new r.default();
                break;
            case "vivo":
                e = new s.default();
                break;
            case "tt":
                e = new c.default();
        }
        return e;
    };
    t.prototype.showRewardVedioAd = function(t, e, o) {
        this.adData && this.adData[1] && this.adData[1].show && this.adData[1].show(t, e, o, 1, n.AdViewEm.rewardVedio);
    };
    t.prototype.showAd = function(t, e) {
        if (GameCof.isInitAccount && e) {
            if (null == GameCof.adConfig) {
                GameCof.adConfig = { a1: 1, a2: 0, a3: 2, a4: 1, a5: 1, a6: 0, a7: 1, a8: 1, a9: 1, a14: 1, ae: 0 };
                console.log("广告配置为空，有问题");
            }
            if (0 == GameCof.adConfig.a1) {
                console.log("总开关已关闭，所以不跳广告");
                return !1;
            }
            var o = 0,
                n = "",
                r = 1;
            if (!e) {
                e = 0;
                o = a.rewardVideo;
                n = "无";
            }
            var s = GameDataValue.getLastLv() + 1;
            if (e == i.upLv || e == i.foodMax || e == i.closeSkill || e == i.equip || e == i.idle) {
                if ("oppo" == GameCof.curPlat) {
                    o = a.custom;
                    r = 2;
                }
                if ("vivo" == GameCof.curPlat) {
                    o = a.custom;
                    r = 2;
                }
                if ("tt" == GameCof.curPlat) {
                    o = a.interstitial;
                    r = 1;
                }
                if ("android" == GameCof.curPlat) {
                    o = a.interstitial;
                    r = 1;
                }
            }
            if (e == i.implant) {
                "oppo" == GameCof.curPlat && (o = a.custom);
                "vivo" == GameCof.curPlat && (o = 0);
                "tt" == GameCof.curPlat && (o = a.banner);
                n = "嵌入";
            }
            if (0 == o) return;
            0 == e && this.goShowAd(t, e, n, r, o);
            if (e == i.upLv) {
                n = "餐厅升级界面点击升级至下一关";
                s >= GameCof.adConfig.a2 ?
                    this.goShowAd(t, e, n, r, o) :
                    console.log("触发广告", "不够等级或间隔时间过短", GameCof.adConfig.a2, s);
            }
            if (e == i.foodMax) {
                n = "单个设备完成满级";
                s >= GameCof.adConfig.a3 ?
                    this.goShowAd(t, e, n, r, o) :
                    console.log("触发广告", "不够等级或间隔时间过短", GameCof.adConfig.a3, s);
            }
            var c = 0;
            c = 6e4 * GameCof.adConfig.a6;
            "vivo" == GameCof.curPlat && (c = 6e4 * GameCof.adConfig.a5);
            if (e == i.closeSkill) {
                n = "关闭一次店铺升级界面";
                if (c > 0)
                    if (s >= GameCof.adConfig.a4 && Date.now() - this.lastCloseTime > c) {
                        this.lastCloseTime = Date.now();
                        this.goShowAd(t, e, n, r, o);
                    } else console.log("触发广告", "不够等级或间隔时间过短", GameCof.adConfig.a4, s);
            }
            if (e == i.equip) {
                n = "关闭装备界面";
                if (GameCof.adConfig.a6 > 0)
                    if (e >= GameCof.adConfig.a5 && Date.now() - this.lastCloseTime > c) {
                        this.lastCloseTime = Date.now();
                        this.goShowAd(t, e, n, r, o);
                    } else console.log("触发广告", "不够等级或间隔时间过短", GameCof.adConfig.a5, e);
            }
            if (e == i.idle) {
                n = "闲置未进行操作";
                var p = 0;
                if (GameCof.adConfig.a7 > 0) {
                    p = 6e4 * GameCof.adConfig.a7;
                    if (this.lastClickTime > 0 && Date.now() - this.lastClickTime > p && this.isCloseCustomAd)
                        if ("tt" == GameCof.curPlat) {
                            if (GameCof.isRecordEnd) {
                                this.lastClickTime = Date.now();
                                this.goShowAd(t, e, n, r, o);
                            }
                        } else {
                            this.lastClickTime = Date.now();
                            this.goShowAd(t, e, n, r, o);
                        }
                }
            }
            e == i.implant && this.goShowAd(t, e, n, r, o);
            if (e == i.box) {
                n = "打开九宫";
                this.goShowAd(t, e, n, r, a.portal);
            }
        }
    };
    t.prototype.goShowAd = function(t, e, o, a, i) {
        i && this.adData && this.adData[1] && this.adData[1].show && this.adData[1].show(t, e, o, a, i);
    };
    t.prototype.hideAd = function(t) {
        if (GameCof.isMiniGame) {
            var e = 0;
            if (t) {
                if (t == i.implant) {
                    "oppo" == GameCof.curPlat && (e = a.custom);
                    "vivo" == GameCof.curPlat && (e = 0);
                    "tt" == GameCof.curPlat && (e = a.banner);
                }
                if (0 == e) return;
                this.adData && this.adData[1] && this.adData[1].hide && this.adData[1].hide(1, e);
            }
        }
    };
    t.prototype.preloadRewardVedioAd = function() {
        if (this.adData) {
            console.log("AdView ---------------stalkooo-- preloadRewardVedioAd   aaaaa");
            this.adData[n.AdViewEm.rewardVedio] ?
                console.log("AdView ----------------- stalkooo preloadRewardVedioAd 111  ") :
                console.log("AdView ----------------- stalkooo preloadRewardVedioAd 222  ");
            this.adData[n.AdViewEm.rewardVedio].preLoad ?
                console.log("AdView ----------------- stalkooo preloadRewardVedioAd 111 aas ") :
                console.log("AdView ----------------- stalkooo preloadRewardVedioAd 222 aas ");
            if (this.adData && this.adData[n.AdViewEm.rewardVedio] && this.adData[n.AdViewEm.rewardVedio].preLoad) {
                console.log("AdView ----------------stalkooo- preloadRewardVedioAd  bbbbb");
                this.adData[n.AdViewEm.rewardVedio].preLoad();
            }
        } else console.log("AdView -----------------stalkooo 没有 初始化完成");
    };
    t.prototype.setAdConfig = function() {
        null == GameCof.adConfig && this.requestAdConfig(this.onRequestConfig, this);
    };
    t.prototype.requestAdConfig = function(t, e) {
        var o = { "a1": 1, "a2": 2, "a3": 3, "a4": 4, "a5": 5, "a6": 3 };
        t.call(e, o);
    };
    t.prototype.onRequestConfig = function(t) {
        GameCof.adConfig = t;
    };
    Object.defineProperty(t.prototype, "Plat", {
        get: function() {
            return "tt" == GameCof.curPlat ?
                window.tt :
                ("oppo" == GameCof.curPlat || "vivo" == GameCof.curPlat) && window.qg;
        },
        enumerable: !1,
        configurable: !0
    });
    return t;
})())();
window.AdView = p;
o.default = p;